package demo;

import ru.yandex.clickhouse.BalancedClickhouseDataSource;
import ru.yandex.clickhouse.ClickHouseConnection;
import ru.yandex.clickhouse.ClickHouseStatement;
import ru.yandex.clickhouse.settings.ClickHouseProperties;

import java.sql.ResultSet;

public class Test3 {
    public static void main(String[] args) throws Exception{
        ClickHouseProperties props = new ClickHouseProperties();
        props.setUser("default");
        props.setPassword("123456");
        BalancedClickhouseDataSource dataSource = new BalancedClickhouseDataSource("jdbc:clickhouse://hadoop10:8123/default", props);
        ClickHouseConnection conn = dataSource.getConnection();
        ClickHouseStatement statement = conn.createStatement();
        ResultSet rs = statement.executeQuery("select id,name,age from test");
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            int age = rs.getInt("age");
            System.out.println("id = "+id+",name = "+name +",age = "+age);
        }
    }
}
